%h1.page_title Upload a Video
%table.new_video
  - form_for @video, :html => {:multipart => true} do |form|
    %tr
      %td.field_title Video:
      %td.field= form.file_field :uploaded_data
      %td.error= error_messages_for :video
    %tr
      %td.field_title *Title:
      %td.field= form.text_field :title
      %td.error= error_message_on :video, :title
    %tr
      %td.field_title Caption: 
      %td.field= form.text_field :caption
      %td.error= error_message_on :video, :caption
    %tr
      %td.field_title Description:
      %td.field= form.text_area :description
      %td.error= error_message_on :video, :description
    %tr
      %td.field_title Galleries:
      %td.field
        - if @galleries.empty?
          No galleries have been created yet.
          %a{:href => new_gallery_url, :title => "Create a new Gallery"}Create one
        - else
          %select{:id => "video[gallery_ids][]", :name => "video[gallery_ids][]", :multiple => true, :size => 8, :width => 10}
            - @galleries.each do |gallery|
              %option{:value => gallery.id, :selected => ("selected" if @video.galleries.include?(gallery))}= gallery.name
      %td.error= error_message_on :photo, :gallery_ids
    %tr
      %td.field_title Thumbnail:
      %td.field
        %div.video_photos
          - @thumbnails.each do |photo|
            %table.video_photo
              %tr
                %td.photo
                  %a{:href => photo_url(photo), :title => (photo.caption ? photo.caption : photo.filename), :alt => (photo.caption ? photo.caption : photo.filename)}
                    %img.photo_thumb{:src => photo.public_filename(:thumb), :title => (photo.caption ? photo.caption : photo.filename), :alt => (photo.caption ? photo.caption : photo.filename)}
              %tr
                %td.check_box= radio_button_tag("video[photo_id]", photo.id)
    %tr
      %td.field_title Options:
      %td
        %table.video_options
          %tr
            %td.video_options_field= check_box_tag("video[random]", 1)
            %td.video_options_field_title One of the videos that cycles on the homepage
            %td.error= error_message_on :video, :random
          %tr
            %td.video_options_field= check_box_tag("video[non_purchasable]", 1)
            %td.video_options_field_title Make unavailable for purchase
            %td.error= error_message_on :video, :non_purchasable
          %tr
            %td.video_options_field=check_box_tag("video[is_private]", 1)
            %td.video_options_field_title Mark this video as private
            %td.error= error_message_on :video, :is_private
    %tr
      %td
      %td= submit_tag 'upload'